﻿Imports BUS
Imports DAO
Imports DTO

Public Class FormTraCuuKhachHang
    Private KH_CRT As KhachHang_CRT

#Region "Load form"
    Private Sub FormTraCuuKhachHang_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        KH_CRT = New KhachHang_CRT()
        CapNhatTieuChuanTraCuu()
        Dim dts As New DataTable()
        dgvKQTraCuu.DataSource = dts
    End Sub
#End Region

#Region "Cập nhật tiêu chuẩn"
    Private Sub CapNhatTieuChuanTraCuu()
        KH_CRT.TenKH = txtTen.Text
        KH_CRT.DiaChi = txtDiaChi.Text
        KH_CRT.DienThoai = txtDienThoai.Text
        KH_CRT.Email = txtEmail.Text
    End Sub
#End Region

#Region "Xử lý nút tra cứu"
    Private Sub ButtonTraCuu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonTraCuu.Click
        CapNhatTieuChuanTraCuu()
        Dim KHBus As New KhachHang_BUS()
        Dim dts As DataTable
        dts = KHBus.TraCuuKhachHang(KH_CRT)
        dgvKQTraCuu.DataSource = dts
    End Sub
#End Region


    Private Sub ButtonThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonThoat.Click
        Me.Close()
    End Sub

    Private Sub CheckBoxDiaChi_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxDiaChi.CheckedChanged
        If (CheckBoxDiaChi.Checked) Then
            txtDiaChi.Enabled = True
        Else
            txtDiaChi.Clear()
            txtDiaChi.Enabled = False
        End If
    End Sub

    Private Sub CheckBoxDienThoai_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxDienThoai.CheckedChanged
        If (CheckBoxDienThoai.Checked) Then
            txtDienThoai.Enabled = True
        Else
            txtDienThoai.Clear()
            txtDienThoai.Enabled = False
        End If
    End Sub

    Private Sub CheckBoxEmail_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxEmail.CheckedChanged
        If (CheckBoxEmail.Checked) Then
            txtEmail.Enabled = True
        Else
            txtEmail.Clear()
            txtEmail.Enabled = False
        End If
    End Sub
End Class